<template>
  <div>
    <select class="form-control" v-model="employeeState" @change="changed">
      <option v-for="option in this.employeeStates" v-bind:value="option.id">{{ option.name }}</option>
    </select>
  </div>
</template>
<script>
// import VueResource from 'vue-resource'
// import api from '../../../api'
export default {
  name: 'EmployeeStatus',
  props: ['selectedEmployeeState','withUnlimit'],
  components: {
    // VueResource
  },
  data: function () {
    return {
      employeeState : this.selectedEmployeeState,
      employeeStates: []
    }
  },
  methods: {
    loaddata: function () {
      if (this.withUnlimit) {
        this.employeeStates = [{ id: -1, name: '不限' }]
        this.employeeStates = this.employeeStates.concat(this.$store.state.sysconfigs.state)
      }
      else
        this.employeeStates = this.$store.state.sysconfigs.state
    },
    changed: function(val){
      this.$emit('empstatechange', this.employeeState)
    }
  },
  created: function () {
    this.loaddata()
  }
}
</script>
